<?php
namespace plugin\ky_black\app\admin\model;

use support\Model;

class Staff extends Model
{
    protected $table = 'ky_staff';
    protected $primaryKey = 'id';
    
    protected $fillable = [
        'department_id', 'role_id', 'username', 'password',
        'real_name', 'phone', 'email', 'avatar', 'status'
    ];

    protected $hidden = [
        'password'
    ];

    protected $casts = [
        'status' => 'boolean',
        'last_login_time' => 'datetime',
        'created_at' => 'datetime',
        'updated_at' => 'datetime'
    ];

    /**
     * 关联部门
     */
    public function department()
    {
        return $this->belongsTo(Department::class, 'department_id', 'department_id');
    }

    /**
     * 关联角色
     */
    public function role()
    {
        return $this->belongsTo(Role::class, 'role_id', 'role_id');
    }
} 